import { createWebHistory, createRouter } from "vue-router";
import Layout from "@/layout";

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index.vue"),
      },
    ],
  },
  {
    path: "/login",
    component: () => import("@/views/login"),
    hidden: true,
  },
  {
    path: "/register",
    component: () => import("@/views/register"),
    hidden: true,
  },
  {
    path: "/:pathMatch(.*)*",
    component: () => import("@/views/error/404"),
    hidden: true,
  },
  {
    path: "/401",
    component: () => import("@/views/error/401"),
    hidden: true,
  },
  {
    path: "/",
    component: Layout,
    redirect: "/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/index"),
        name: "Index",
        meta: { title: "首页", icon: "fa-home-lg-alt", affix: true },
      },
    ],
  },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: () => import("@/views/system/user/profile/index"),
        name: "Profile",
        meta: { title: "个人中心", icon: "user" },
      },
    ],
  },
  {
    path: "/system/user-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "role/:userId(\\d+)",
        component: () => import("@/views/system/user/authRole"),
        name: "AuthRole",
        meta: { title: "分配角色", activeMenu: "/system/user" },
      },
    ],
  },
  {
    path: "/system/role-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "user/:roleId(\\d+)",
        component: () => import("@/views/system/role/authUser"),
        name: "AuthUser",
        meta: { title: "分配用户", activeMenu: "/system/role" },
      },
    ],
  },
  {
    path: "/system/dict-data",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index/:dictId(\\d+)",
        component: () => import("@/views/system/dict/data"),
        name: "Data",
        meta: { title: "字典数据", activeMenu: "/system/dict" },
      },
    ],
  },
  {
    path: "/monitor/job-log",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index",
        component: () => import("@/views/monitor/job/log"),
        name: "JobLog",
        meta: { title: "调度日志", activeMenu: "/monitor/job" },
      },
    ],
  },
  {
    path: "/tool/gen-edit",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index/:tableId(\\d+)",
        component: () => import("@/views/tool/gen/editTable"),
        name: "GenEdit",
        meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
      },
    ],
  },
  {
    path: "/comprehensiveInformation",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "综合信息管理", icon: "comprehensiveInformation" },
    children: [
      {
        path: "seismicEvents",
        component: () => import("@/views/comprehensiveInformation/seismicEvents/index"),
        name: "seismicEvents",
        meta: { title: "地震事件管理", icon: "seismicEvents" },
      },
      {
        path: "fieldPersonnelInformation",
        component: () => import("@/views/comprehensiveInformation/fieldPersonnelInformation/index"),
        name: "fieldPersonnelInformation",
        meta: { title: "现场人员信息管理", icon: "fieldPersonnelInformation",noCache: true  },
      },
      {
        path: "headquarters",
        component: () => import("@/views/comprehensiveInformation/headquarters/index"),
        name: "headquarters",
        meta: { title: "指挥部管理", icon: "headquarters",noCache: true  },
      },
      {
        path: "carManage",
        component: () => import("@/views/comprehensiveInformation/carManage/index"),
        name: "carManage",
        meta: { title: "车辆管理", icon: "carManage",noCache: true  },
      },
      {
        path: "goodsManagee",
        component: () => import("@/views/comprehensiveInformation/goodsManagee/index"),
        name: "goodsManagee",
        meta: { title: "物资管理", icon: "goodsManagee",noCache: true  },
      },
      {
        path: "knowledge",
        component: () => import("@/views/comprehensiveInformation/knowledge/index"),
        name: "knowledge",
        meta: { title: "知识库管理", icon: "knowledge",noCache: true  },
      },
      {
        path: "buildingStructure",
        component: () => import("@/views/comprehensiveInformation/buildingStructure/index"),
        name: "buildingStructure",
        meta: { title: "房屋结构类型管理", icon: "buildingStructure",noCache: true  },
      },   
    ],
  },
  {
    path: "/disasterArea",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: {title: "灾区范围", icon: "disasterArea"},
    children: [
      {
        path: "disasterArea",
        component: () => import("@/views/disasterArea/index"),
        name: "disasterArea",
        meta: { title: "灾区范围", icon: "disasterArea",noCache: true },
      }
    ],
  },
  {
    path: "/fastDisasterAnalysis",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "灾情快速判别与分析", icon: "fastDisasterAnalysis" },
    children: [
      {
        path: "fastSeismicInfluence",
        component: () => import("@/views/fastDisasterAnalysis/fastSeismicInfluence/index"),
        name: "fastSeismicInfluence",
        meta: { title: "地震影响场快速生成", icon: "fastSeismicInfluence",noCache: true },
      },
      {
        path: "casualtiesEstimate",
        component: () => import("@/views/fastDisasterAnalysis/casualtiesEstimate/index"),
        name: "casualtiesEstimate",
        meta: { title: "人员伤亡估计", icon: "casualtiesEstimate",noCache: true  },
      },
      {
        path: "buildingDamageEstimate",
        component: () => import("@/views/fastDisasterAnalysis/buildingDamageEstimate/index"),
        name: "buildingDamageEstimate",
        meta: { title: "房屋破坏估计", icon: "buildingDamageEstimate",noCache: true  },
      },
    ],
  },
  {
    path: "/fieldWork",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "现场工作管理", icon: "fieldWork" },
    children: [
      {
        path: "surveyManage",
        component: () => import("@/views/fieldWork/surveyManage/index"),
        name: "surveyManage",
        meta: { title: "调查组管理", icon: "surveyManage",noCache: true  },
      },
      {
        path: "surveyAudit",
        component: () => import("@/views/fieldWork/surveyAudit/main"),
        name: "surveyAudit",
        meta: { title: "调查数据审核", icon: "surveyAudit" },
        children: [
          {
            path: "samplePointHouseAudit",
            component: () => import("@/views/fieldWork/surveyAudit/samplePointHouseAudit/index"),
            name: "samplePointHouseAudit",
            meta: { title: "抽样点房屋数据审核", icon: "samplePointHouseAudit",noCache: true },
          },
          {
            path: "housUnitSampleAudit",
            component: () => import("@/views/fieldWork/surveyAudit/housUnitSampleAudit/index"),
            name: "housUnitSampleAudit",
            meta: { title: "房屋单体样本数据审核", icon: "housUnitSampleAudit",noCache: true },
          },
          {
            path: "lifelineEngineerAudit",
            component: () => import("@/views/fieldWork/surveyAudit/lifelineEngineerAudit/index"),
            name: "lifelineEngineerAudit",
            meta: { title: "生命线工程数据审核", icon: "lifelineEngineerAudit",noCache: true },
          },
        ],
      }, 
      {
        path: "informManage",
        component: () => import("@/views/fieldWork/informManage/index"),
        name: "informManage",
        meta: { title: "通知管理", icon: "informManage",noCache: true  },
      },
      {
        path: "taskManage",
        component: () => import("@/views/fieldWork/taskManage/index"),
        name: "taskManage",
        meta: { title: "调查任务管理", icon: "taskManage",noCache: true  },
      },
      {
        path: "dailySurvey",
        component: () => import("@/views/fieldWork/dailySurvey/index"),
        name: "dailySurvey",
        meta: { title: "每日调查跟踪", icon: "dailySurvey",noCache: true  },
      },
    ],
  },
  {
    path: "/disasterManage",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "灾情数据管理", icon: "disasterManage" },
    children: [
      {
        path: "fieldSurveyManage",
        component: () => import("@/views/disasterManage/fieldSurveyManage/main"),
        name: "fieldSurveyManage",
        meta: { title: "现场调查数据管理", icon: "fieldSurveyManage" },
        children: [
          {
            path: "samplePointCheck",
            component: () => import("@/views/disasterManage/fieldSurveyManage/samplePointCheck/index"),
            name: "samplePointCheck",
            meta: { title: "抽样点数据查看", icon: "samplePointCheck",noCache: true },
          },
          {
            path: "samplePointHouseCheck",
            component: () => import("@/views/disasterManage/fieldSurveyManage/samplePointHouseCheck/index"),
            name: "samplePointHouseCheck",
            meta: { title: "抽样点房屋数据查看", icon: "samplePointHouseCheck",noCache: true },
          },
          {
            path: "housUnitSampleCheck",
            component: () => import("@/views/disasterManage/fieldSurveyManage/housUnitSampleCheck/index"),
            name: "housUnitSampleCheck",
            meta: { title: "房屋单体样本数据查看", icon: "housUnitSampleCheck",noCache: true },
          },
          {
            path: "lifelineEngineerCheck",
            component: () => import("@/views/disasterManage/fieldSurveyManage/lifelineEngineerCheck/index"),
            name: "lifelineEngineerCheck",
            meta: { title: "生命线工程数据查看", icon: "lifelineEngineerCheck",noCache: true },
          },
          {
            path: "kilometerGrid",
            component: () => import("@/views/disasterManage/fieldSurveyManage/kilometerGrid/index"),
            name: "kilometerGrid",
            meta: { title: "建筑物公里格网", icon: "kilometerGrid",noCache: true },
          }
        ],
      },
      {
        path: "disasterEmergencyReportManage",
        component: () => import("@/views/disasterManage/disasterEmergencyReportManage/index"),
        name: "disasterEmergencyReportManage",
        meta: { title: "灾情急报数据管理", icon: "disasterEmergencyReportManage",noCache: true },
      },
      {
        path: "basicDataManage",
        component: () => import("@/views/disasterManage/basicDataManage/index"),
        name: "basicDataManage",
        meta: { title: "基础数据管理", icon: "basicDataManage",noCache: true },
      },
      {
        path: "lifelineEngineeringData",
        component: () => import("@/views/disasterManage/lifelineEngineeringData/index"),
        name: "lifelineEngineeringData",
        meta: { title: "生命线工程数据", icon: "lifelineEngineeringData",noCache: true },
      },
      {
        path: "remoteSense",
        component: () => import("@/views/disasterManage/remoteSense/index"),
        name: "remoteSense",
        meta: { title: "遥感数据管理", icon: "remoteSense",noCache: true },
      },
      {
        path: "instrumentIntensity",
        component: () => import("@/views/disasterManage/instrumentIntensity/index"),
        name: "instrumentIntensity",
        meta: { title: "仪器烈度数据管理", icon: "instrumentIntensity",noCache: true },
      },
    ],
  },
  {
    path: "/seismicIntensityMap",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "地震烈度图", icon: "seismicIntensityMap" },
    children: [
      {
        path: "seismicIntensityMapData",
        component: () => import("@/views/seismicIntensityMap/seismicIntensityMapData/index"),
        name: "seismicIntensityMapData",
        meta: { title: "地震烈度图资料", icon: "seismicIntensityMapData" },
      },
      {
        path: "seismicIntensityMapDraw",
        component: () => import("@/views/seismicIntensityMap/seismicIntensityMapDraw/index"),
        name: "seismicIntensityMapDraw",
        meta: { title: "地震烈度图绘制", icon: "seismicIntensityMapDraw" },
      },
    ],
  },
  {
    path: "/lossReportManage",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "地震灾害损失报表管理", icon: "lossReportManage" },
    children: [
      {
        path: "lossReportOn",
        component: () => import("@/views/lossReportManage/lossReportOn/index"),
        name: "lossReportOn",
        meta: { title: "地震灾害损失报表上报", icon: "seismicEvents" },
      },
      {
        path: "lossReportAudit",
        component: () => import("@/views/lossReportManage/lossReportAudit/index"),
        name: "lossReportAudit",
        meta: { title: "地震灾害损失报表审核", icon: "lossReportAudit",noCache: true  },
      },    
    ],
  },
  {
    path: "/directLossAssess",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "地震灾害直接损失评估", icon: "directLossAssess" },
    children: [
    	{
        path: "delimitEvaluationsubarea",
        component: () => import("@/views/directLossAssess/delimitEvaluationsubarea/index"),
        name: "delimitEvaluationsubarea",
        meta: { title: "划定评估子区", icon: "delimitEvaluationsubarea" },
      },
      {
        path: "resetPrice",
        component: () => import("@/views/directLossAssess/resetPrice/index"),
        name: "resetPrice",
        meta: { title: "设定重置单价", icon: "resetPrice" },
      },
      {
        path: "floorArea",
        component: () => import("@/views/directLossAssess/floorArea/index"),
        name: "floorArea",
        meta: { title: "设定总建筑面积", icon: "floorArea",noCache: true  },
      }, 
      {
        path: "directEconomicLosses",
        component: () => import("@/views/directLossAssess/directEconomicLosses/main"),
        name: "directEconomicLosses",
        meta: { title: "房屋直接经济损失评估", icon: "directEconomicLosses" },
        children: [
          {
            path: "failureRatio",
            component: () => import("@/views/directLossAssess/directEconomicLosses/failureRatio/index"),
            name: "failureRatio",
            meta: { title: "房屋破坏比计算", icon: "failureRatio"},
          },
          {
            path: "lossRatio",
            component: () => import("@/views/directLossAssess/directEconomicLosses/lossRatio/index"),
            name: "lossRatio",
            meta: { title: "房屋损失比计算", icon: "lossRatio"},
          },
          {
            path: "directEconomic",
            component: () => import("@/views/directLossAssess/directEconomicLosses/directEconomic/index"),
            name: "directEconomic",
            meta: { title: "直接经济损失计算", icon: "directEconomic"},
          },
          
        ],
      },
      {
        path: "decorationLosses",
        component: () => import("@/views/directLossAssess/decorationLosses/main"),
        name: "decorationLosses",
        meta: { title: "房屋装修损失评估", icon: "decorationLosses" },
        children: [
          {
            path: "decorationTotalArea",
            component: () => import("@/views/directLossAssess/decorationLosses/decorationTotalArea/index"),
            name: "decorationTotalArea",
            meta: { title: "中高档房屋装修总面积计算", icon: "decorationTotalArea" },
          },
          {
            path: "decorationDamageLossRatio",
            component: () => import("@/views/directLossAssess/decorationLosses/decorationDamageLossRatio/index"),
            name: "decorationDamageLossRatio",
            meta: { title: "房屋装修破坏损失比", icon: "decorationDamageLossRatio"},
          },
          {
            path: "decorationDirectEconomicLosses",
            component: () => import("@/views/directLossAssess/decorationLosses/decorationDirectEconomicLosses/index"),
            name: "decorationDirectEconomicLosses",
            meta: { title: "房屋装修直接经济损失计算", icon: "decorationDirectEconomicLosses" },
          },
          
        ],
      },
      {
        path: "indoorAndOutdoorProperty",
        component: () => import("@/views/directLossAssess/indoorAndOutdoorProperty/index"),
        name: "indoorAndOutdoorProperty",
        meta: { title: "室内外财产损失评估", icon: "indoorAndOutdoorProperty",noCache: false },
      },
      {
        path: "lifelineSystem",
        component: () => import("@/views/directLossAssess/lifelineSystem/index"),
        name: "lifelineSystem",
        meta: { title: "生命线系统直接损失评估", icon: "lifelineSystem",noCache: false  },
      },
      {
        path: "enterprises",
        component: () => import("@/views/directLossAssess/enterprises/index"),
        name: "enterprises",
        meta: { title: "企事业直接经济损失评估", icon: "enterprises",noCache: false  },
      },
      {
        path: "lossesSummary",
        component: () => import("@/views/directLossAssess/lossesSummary/index"),
        name: "lossesSummary",
        meta: { title: "地震直接经济损失汇总", icon: "lossesSummary",noCache: true  },
      },
      {
        path: "earthquakeRelief",
        component: () => import("@/views/directLossAssess/earthquakeRelief/index"),
        name: "earthquakeRelief",
        meta: { title: "地震救灾投入费用评估", icon: "earthquakeRelief",noCache: true  },
      },
      {
        path: "personnelCasualties",
        component: () => import("@/views/directLossAssess/personnelCasualties/index"),
        name: "personnelCasualties",
        meta: { title: "人员伤亡分析", icon: "personnelCasualties",noCache: true  },
      },
      {
        path: "resettlePeople",
        component: () => import("@/views/directLossAssess/resettlePeople/index"),
        name: "resettlePeople",
        meta: { title: "需安置人数评估", icon: "resettlePeople",noCache: true  },
      },
    ],
  },
  // 抽样点数据统计
  {
    path: "/samplingPointData",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: { title: "抽样点数据统计", icon: "samplingPointData" },
    children: [
      {
        path: "damageReport",
        component: () => import("@/views/samplingPointData/damageReport/index"),
        name: "damageReport",
        meta: { title: "灾情急报统计", icon: "damageReport" },
      },
      {
        path: "sampleSurveyReport",
        component: () => import("@/views/samplingPointData/sampleSurveyReport/index"),
        name: "sampleSurveyReport",
        meta: { title: "抽样调查统计", icon: "sampleSurveyReport" },
      },
      {
        path: "commentAreaClassification",
        component: () => import("@/views/samplingPointData/commentAreaClassification/index"),
        name: "commentAreaClassification",
        meta: { title: "评估区分类统计", icon: "commentAreaClassification" },
      },    
    ],
  },
  {
    path: "/earthEvaluaDisasterReport",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: {title: "地震灾评报告", icon: "earthEvaluaDisasterReport"},
    children: [
      {
        path: "reportModelManage",
        component: () => import("@/views/earthEvaluaDisasterReport/reportModelManage/index"),
        name: "reportModelManage",
        meta: { title: "报告模板管理", icon: "reportModelManage",noCache: true },
      },
      {
        path: "creatReport",
        component: () => import("@/views/earthEvaluaDisasterReport/creatReport/index"),
        name: "creatReport",
        meta: { title: "生成报告", icon: "creatReport",noCache: true },
      },
    ],
  },
  {
    path: "/screenData",
    component: Layout,
    hidden: true,
    redirect: "noRedirect",
    meta: {title: "大屏关联数据管理", icon: "screenData"},
    children: [
      {
        path: "index1",
        component: () => import("@/views/screenData/index"),
        name: "reportModelManage",
        meta: { title: "大屏关联数据管理", icon: "index1",noCache: true },
      },
    ],
  }
];

const router = createRouter({
  history: createWebHistory("xczh"),
  routes: constantRoutes,
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
